local skel = fk.CreateSkill {
  name = "#lb__yaoduan_choose",
}

Fk:loadTranslationTable {
  ["#lb__yaoduan_choose"] = "摇缎",
  ["#lb__yaoduan"] = "摇缎：你可以弃置/重铸任意张梅花手牌",
  ["#lb__yaoduan_choose-dis"] = "摇缎：你可以弃置任意张梅花手牌，令至多 %arg 名角色各摸 %arg 张牌",
  ["#lb__yaoduan_choose-recast"] = "摇缎：你可以重铸任意张梅花手牌，令至多 %arg 名角色各弃置一张牌",
}

skel:addEffect("active", {
  prompt = function(self, player, selected_cards, selected_targets)
    if #selected_cards > 0 then
      local n = selected_cards
      --[[
      local n = {}
      table.forEach(selected_cards,function (id)
        table.insertIfNeed(n,Fk:getCardById(id).type)
      end)
      --]]
      if self.interaction.data == "discard" then
        return "#lb__yaoduan_choose-dis:::" .. #n
      else
        return "#lb__yaoduan_choose-recast:::" .. #n
      end
    end
    return "#lb__yaoduan"
  end,
  interaction = function(self, player)
    return UI.ComboBox {
      choices = { "discard", "recast" },
    }
  end,
  card_filter = function(self, player, to_select, selected)
    if Fk:getCardById(to_select).suit == Card.Club and table.contains(player:getCardIds("h"), to_select) then
      if self.interaction.data == "discard" then
        return not player:prohibitDiscard(to_select)
      end
      return true
    end
    return false
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    local n = selected_cards
    --[[
    local n = {}
    table.forEach(selected_cards,function (id)
      table.insertIfNeed(n,Fk:getCardById(id).type)
    end)
    --]]
    if self.interaction.data == "recast" then
      return not to_select:isNude() and #selected < #n
    end
    return #selected < #n
  end,
  feasible = function(self, player, selected, selected_cards, card)
    local n = selected_cards
    --[[
    local n = {}
    table.forEach(selected_cards,function (id)
      table.insertIfNeed(n,Fk:getCardById(id).type)
    end)
    --]]
    return (#selected > 0) and (#selected_cards > 0) and (#n >= #selected)
  end,
})

return skel
